"use client";

import { Edit, useForm } from "@refinedev/antd";
import { Form, Input, InputNumber, Select } from "antd";

export default function ProductEdit() {
    const { formProps, saveButtonProps } = useForm({});

    return (
        <Edit saveButtonProps={saveButtonProps}>
            <Form {...formProps} layout="vertical">
                <Form.Item label="ID" name="id">
                    <Input disabled />
                </Form.Item>

                <Form.Item
                    label="商品名称"
                    name="name"
                    rules={[{ required: true, message: "请输入商品名称" }]}
                >
                    <Input placeholder="请输入商品名称" />
                </Form.Item>

                <Form.Item
                    label="商品描述"
                    name="description"
                    rules={[{ required: true, message: "请输入商品描述" }]}
                >
                    <Input.TextArea rows={4} placeholder="请输入商品描述" />
                </Form.Item>

                <Form.Item
                    label="价格"
                    name="price"
                    rules={[{ required: true, message: "请输入价格" }]}
                >
                    <InputNumber
                        min={0}
                        precision={2}
                        style={{ width: "100%" }}
                        addonBefore="¥"
                    />
                </Form.Item>

                <Form.Item
                    label="库存"
                    name="stock"
                    rules={[{ required: true, message: "请输入库存" }]}
                >
                    <InputNumber min={0} style={{ width: "100%" }} />
                </Form.Item>

                <Form.Item
                    label="分类"
                    name="category"
                    rules={[{ required: true, message: "请选择分类" }]}
                >
                    <Select
                        options={[
                            { value: "electronics", label: "电子产品" },
                            { value: "clothing", label: "服装" },
                            { value: "food", label: "食品" },
                            { value: "books", label: "图书" },
                        ]}
                    />
                </Form.Item>

                <Form.Item
                    label="状态"
                    name="status"
                    rules={[{ required: true }]}
                >
                    <Select
                        options={[
                            { value: "active", label: "上架" },
                            { value: "inactive", label: "下架" },
                        ]}
                    />
                </Form.Item>
            </Form>
        </Edit>
    );
}

